#include "include/debug.h"
#include "include/filehandle.h"
#include <stdlib.h>
#pragma warning(disable : 4996)

extern MemoryNode<dword> CodeMem[65536];
extern MemoryNode<byte> DataMem[65536];

extern bool RUNNING, ERROR, Zero, Sign;

extern word CodeH, CodeL;
extern IREG intRegs[128];
extern FREG floatReg[64];
extern DREG doublReg[64];

int main(int argc, char *argv[])
{
	if (argc == 1)
	{
		printf("Usage: SandBox2.5.0 <filename> <options> <values>\n");
		exit(-2);
	}
	else if (argc == 2)
	{
		fHeader fMessage = getHeader(argv[1]);
		loadImage(argv[1], fMessage);
		while (RUNNING)
			selector(loader());
	}
	else if (argc >= 3)
	{
		fHeader fMessage = getHeader(argv[1]);
		loadImage(argv[1], fMessage);
		char *option = argv[2] + 1;
		if (option[0] == '-')
		{
		}
		else
		{
			switch (option[0])
			{
			case 'r':
				while (RUNNING)
					selector(loader());
				break;
			case 'd':
				debugger();
				break;
			case '?':
				printf("Usage: SandBox2.5.0 <filename> <options> <values>\n");
				printf("Option r: run through(as None Options);\n");
				printf("Option d: run in interactive debugger;\n");
				break;
			}
		}
	}
}